package torres.item.effect;

import torres.entity.Entity;

/**
 * @author Torres
 *An Effect that decreases the mana of the specified Entity.
 */
@SuppressWarnings("serial")
public class DecrementManaEffect implements Effect {
	int manaValue;
	
	/**
	 * Create a DecrementManaEffect with the specified value.
	 * @param manaValue The value to be decremented.
	 */
	public DecrementManaEffect(int manaValue) {
		
		this.setManaValue(manaValue);
	}
	
	/**
	 * Use this effect on the specified entity.
	 * @param The Entity that is using this item. 
	 */
	@Override
	public void use(Entity e) {
		e.decCurrMana(this.getManaValue());
	}
	
	
	/**
	 * Tests to see if this effect can successfully be applied to the specified Entity. 
	 * @param e The Entity on which to test if this affect can be applied.
	 * @return True if this effect can be applied to the Entity, false otherwise.
	 */
	public boolean canUse(Entity e) {
		return e.getCurrMana() >= this.getManaValue();
	}
	
	
	/**
	 * Set the amount of mana to be decremented. 
	 * @param manaValue The value of the mana to be decremented.
	 */
	private void setManaValue(int manaValue) {
		
		this.manaValue = manaValue;
	}
	
	/**
	 * Get the amount of mana to be decremented.
	 * @return The value of the mana to be decremented.
	 */
	private int getManaValue() {
		
		return this.manaValue;
	}
}
